using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Experiment;

public class FormExperiment : Form, IExperiment
{
	private bool isQuiting = false;

	public ExperimentDatas experiment = new ExperimentDatas();

	public ExperimentDB db = new ExperimentDB();

	public string experimentPath = null;

	private bool isSaved = false;

	public static bool IsRun;

	private FormConfig formConfig = new FormConfig();

	private FormIsotopes formIsotopes = new FormIsotopes();

	private FormStandard formStandard = new FormStandard();

	private FormScan formScan = new FormScan();

	private FormSamples formSamples = new FormSamples();

	private FormConcentration formConcen = new FormConcentration();

	private FormResults formResults = new FormResults();

	private FormCalibration formMethod = new FormCalibration();

	private FormRatio formRatio = new FormRatio();

	private FormReport formReport = new FormReport();

	private bool createFromOld = false;

	private IContainer components = null;

	private GroupBox groupBox13;

	private Label label8;

	private MenuStrip menuStrip1;

	private ToolStripMenuItem kHome;

	private ToolStripMenuItem tsmiSave;

	private ToolStripMenuItem tsmiSaveAs;

	private ToolStrip toolStrip1;

	private ToolStripButton tsbtnConfig;

	private ToolStripButton tsbtnIsotopes;

	private ToolStripButton tsbtnScan;

	private ToolStripButton tsbtnStandards;

	private ToolStripButton tsbtnSamples;

	private ToolStripButton tsbtnConcen;

	private ToolStripButton tsbtnResults;

	private ToolStripButton tsbtnMethod;

	private ToolStripButton tsbtnRatio;

	private ToolStripButton tsbtnReport;

	private ToolStripMenuItem tsmi_LIMS;

	private Panel panelTest;

	public int CurrentStatus => experiment.Scan.currentStatus;

	public bool IsActive => experiment.IsRun;

	public event EventHandler updateToolstrip = null;

	public event EventHandler analyseFinish = null;

	public event DelegateExpProgress ExpEvent = null;

	public FormExperiment(string dbPath, bool isOpen = false)
	{
		InitializeComponent();
		ApplyResources();
		experimentPath = dbPath;
		InitDB();
		if (!isOpen)
		{
			createFromOld = true;
			experiment.Dirty.SetAll();
		}
		isSaved = isOpen;
	}

	private void FormExperiment_Load(object sender, EventArgs e)
	{
		base.WindowState = FormWindowState.Maximized;
		Control.CheckForIllegalCrossThreadCalls = false;
		Task.Factory.StartNew(delegate
		{
			LoadExperimentDatas();
		});
		experiment.EventExperiment += experiment_EventExperiment;
		LoadInstrumentConfig();
		tsbtnConfig.PerformClick();
	}

	private void UPSManager_errorEvent(object sender, EventArgs e)
	{
		throw new NotImplementedException();
	}

	private void ApplyResources()
	{
		kHome.Text = Lang.Txt("iMass.Menu.File.Text");
		tsbtnConcen.Text = Lang.Txt("FormExperiment.STDConcentration.Text");
		tsbtnConfig.Text = Lang.Txt("FormExperiment.ScanCondition.Text");
		tsbtnIsotopes.Text = Lang.Txt("FormExperiment.AnalyteElement.Text");
		tsbtnMethod.Text = Lang.Txt("FormExperiment.CalibrationSetting.Text");
		tsbtnRatio.Text = Lang.Txt("FormExperiment.RatioSettings.Text");
		tsbtnReport.Text = Lang.Txt("FormExperiment.Report.Text");
		tsbtnResults.Text = Lang.Txt("FormExperiment.ScanResult.Text");
		tsbtnSamples.Text = Lang.Txt("FormExperiment.SampleList.Text");
		tsbtnScan.Text = Lang.Txt("FormExperiment.ScanParam.Text");
		tsbtnStandards.Text = Lang.Txt("FormExperiment.InterSet.Text");
		tsmiSave.Text = Lang.Txt("FormExperiment.Save.Text");
		tsmiSaveAs.Text = Lang.Txt("FormExperiment.SaveAs.Text");
	}

	private bool InitDB()
	{
		if (File.Exists(experimentPath))
		{
			return db.Init(experimentPath);
		}
		return false;
	}

	private void FormExperiment_FormClosing(object sender, FormClosingEventArgs e)
	{
		if (experiment == null)
		{
			return;
		}
		if (experiment.IsRun)
		{
			MessageBox.Show(Lang.Txt("FormExperiment.MessageBox.IsRunning.Text"), Lang.Txt("AddFormExperiment.Warn"), MessageBoxButtons.OK);
			e.Cancel = true;
			return;
		}
		if (!isSaved)
		{
			switch (MessageBox.Show(Lang.Txt("FormExperiment.MessageBox.SaveingResult.Text"), Lang.Txt("FormExperiment.MessageBox.Analysis.Text"), MessageBoxButtons.YesNoCancel))
			{
			case DialogResult.Cancel:
				e.Cancel = true;
				break;
			case DialogResult.Yes:
				if (SaveDB() == 0)
				{
					e.Cancel = true;
				}
				isSaved = true;
				break;
			}
		}
		else
		{
			CheckDirty();
		}
		if (e.Cancel)
		{
			return;
		}
		experiment.EventExperiment -= experiment_EventExperiment;
		isQuiting = true;
		formConfig.Close();
		formIsotopes.Close();
		formScan.Close();
		formStandard.Close();
		formConcen.Close();
		formMethod.Close();
		formRatio.Close();
		formReport.Close();
		formResults.Close();
		formSamples.Close();
		experiment = null;
		db.Close();
		if (isSaved)
		{
			return;
		}
		try
		{
			File.Delete(experimentPath);
		}
		catch
		{
		}
	}

	private void PerformProgressStep(ProgressBar bar)
	{
		Invoke((MethodInvoker)delegate
		{
			bar.PerformStep();
		});
	}

	public bool AddSamples(SamplesInfos sample)
	{
		experiment.Samples.Add(sample);
		experiment.OnSampleSelfChanged();
		return true;
	}

	private void AsynSaveDb(object sender, EventArgs e)
	{
		ProgressBar bar = sender as ProgressBar;
		experiment.CurrentPlat.name = "Experiment";
		experiment.CurrentLens.name = "Experiment";
		experiment.CurrentPlasma.Name = "Experiment";
		experiment.CurrentRFS.name = "Experiment";
		experiment.CurrentInjector.Name = "Experiment";
		experiment.StableConfig.Name = "Experiment";
		db.SavePlatform(experiment.CurrentPlat);
		db.SavePlasma(experiment.CurrentPlasma);
		db.SaveX2Lens(experiment.CurrentLens);
		db.SaveRFS(experiment.CurrentRFS);
		db.SaveInjector(experiment.CurrentInjector);
		db.SaveAutoSampleTable(experiment.AutosampleTable);
		db.SaveStableConfig(experiment.StableConfig);
		if (experiment.Dirty.SurveyRegionsDirty)
		{
			db.DeleteExpSurveyRegions();
			db.SaveExpSurveyRegions(experiment.SurveyRegions);
			experiment.Dirty.SurveyRegionsDirty = false;
		}
		if (experiment.Dirty.BlankCalibrationDirty)
		{
			db.DeleteExpBlankCalibration();
			db.SaveExpBlankCalibration(experiment.BlankCalibration);
			experiment.Dirty.BlankCalibrationDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.ScanRegionsDirty)
		{
			db.DeleteExpScanRegions();
			db.SaveExpScanRegions(experiment.ScanRegions);
			experiment.Dirty.ScanRegionsDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.PeakRegionsDirty)
		{
			db.DeleteExpPeakRegions();
			db.SaveExpPeakRegions(experiment.PeakRegions);
			experiment.Dirty.PeakRegionsDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.IsotopeInfoDirty)
		{
			db.DeleteExpIsotopes();
			db.SaveExpIsotopes(experiment.Isotopes);
			experiment.Dirty.IsotopeInfoDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.SamplesDirty)
		{
			db.DeleteExpSamples();
			db.SaveExpSamples(experiment.Samples);
			experiment.Dirty.SamplesDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.STDConcDirty)
		{
			db.DeleteExpStdConcs();
			db.SaveExpStdConcs(experiment.StdConcentration);
			db.DeleteQCSConcs();
			db.SaveQCSConcs(experiment.QCSConcentration);
			experiment.Dirty.STDConcDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.ResultsDirty)
		{
			db.DeleteExpResults();
			db.SaveExpResults(experiment.Results);
			PerformProgressStep(bar);
			db.DeleteExpStatistics();
			db.SaveExpStatistics(experiment.Statistics);
			PerformProgressStep(bar);
			db.DeleteExpRatioResults();
			db.SaveExpRatioResults(experiment.RatioResults);
			PerformProgressStep(bar);
			db.DeleteExpRatioStatistics();
			db.SaveExpRatioStatstics(experiment.RatioStat);
			PerformProgressStep(bar);
			experiment.Dirty.ResultsDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.CurveDirty)
		{
			db.DeleteExpCurves();
			db.SaveExpCurves(experiment.Curves);
			experiment.Dirty.CurveDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.RatiosDirty)
		{
			db.DeleteExpIsotopeRatio();
			db.SaveExpIsotopeRatios(experiment.Ratios);
			experiment.Dirty.RatiosDirty = false;
		}
		PerformProgressStep(bar);
		if (experiment.Dirty.SpectrumDirty)
		{
			db.DeleteExpSpectrums();
			db.SaveExpSpectrums(experiment.Spectrums);
			experiment.Dirty.SpectrumDirty = false;
		}
		db.SaveExpParams(experiment.Scan);
		db.SaveReportParams(experiment.ReportParams);
		db.WriteToLocal();
		PerformProgressStep(bar);
	}

	private void ProcessAndSaveSingleSample(SamplesInfos sample)
	{
		FormWait wait = new FormWait();
		wait.Text = Lang.Txt("FormExperiment.MessageBox.SaveData.Text");
		wait.Run += delegate
		{
			if (sample.type == 1 || sample.type == 2 || sample.refer)
			{
				if (Detector.detectorConfig.IsNewBoard)
				{
					experiment.RecalculatedAllForNew();
				}
				else
				{
					experiment.RecalculatedAll();
				}
			}
			ManualSaveDB();
		};
		wait.Complete += delegate
		{
			if (sample.type == 1 || sample.type == 2 || sample.refer)
			{
				formResults.RefreshResults();
			}
			else
			{
				formResults.RefreshResultsSingle(sample);
			}
		};
		wait.ShowDialog();
	}

	private void CheckDirty(bool tip = true)
	{
		if (experiment.Dirty.HasDirty)
		{
			DialogResult result = DialogResult.Yes;
			if (tip)
			{
				result = MessageBox.Show(Lang.Txt("FormExperiment.MessageBox.DBChange.Text"), Lang.Txt("FormExperiment.MessageBox.Analysis.Text"), MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
			}
			if (result == DialogResult.Yes)
			{
				FormWait wait = new FormWait();
				wait.Text = Lang.Txt("FormExperiment.MessageBox.SaveData.Text");
				wait.Run += AsynSaveDb;
				wait.ShowDialog();
			}
		}
		else if (!db.WriteToLocal())
		{
			MessageBox.Show(Lang.Txt("AddFormExperiment.Warn"), Lang.Txt("AddFormExperiment.SaveFailed"));
		}
	}

	private int SaveDB(bool saveAs = false)
	{
		SaveFileDialog dlg = new SaveFileDialog();
		dlg.Filter = "测试文件(*.ncs)|*.ncs";
		dlg.FileName = Path.GetFileName(experimentPath);
		if (dlg.ShowDialog() == DialogResult.OK)
		{
			try
			{
				string fileName = dlg.FileName;
				if (File.Exists(fileName))
				{
					File.Delete(fileName);
				}
				if (!saveAs && File.Exists(experimentPath))
				{
					File.Delete(experimentPath);
				}
				experimentPath = fileName;
				db.ReConnect(experimentPath);
				CheckDirty(tip: false);
				Text = Path.GetFileNameWithoutExtension(experimentPath);
				if (this.updateToolstrip != null)
				{
					this.updateToolstrip(this, null);
				}
				return 1;
			}
			catch (Exception ex)
			{
				Log.InsertLog("Experiment", "Save datas error.", ex.Message, (Severity)3);
				return -1;
			}
		}
		return 0;
	}

	private void tsmiSave_Click(object sender, EventArgs e)
	{
		if (!isSaved)
		{
			if (SaveDB() == 1)
			{
				isSaved = true;
			}
		}
		else
		{
			CheckDirty(tip: false);
		}
	}

	public void ManualSaveDB()
	{
		experiment.Dirty.SetAll();
		if (!isSaved)
		{
			if (SaveDB() == 1)
			{
				isSaved = true;
			}
		}
		else
		{
			CheckDirty(tip: false);
		}
	}

	private void tsmiSaveAs_Click(object sender, EventArgs e)
	{
		experiment.Dirty.SetAll();
		if (SaveDB(saveAs: true) == 1)
		{
			isSaved = true;
		}
	}

	public void LoadBlankCalibration()
	{
		experiment.BlankCalibration = db.GetExpBlankCalibration().ToList();
		if (experiment.BlankCalibration == null || experiment.BlankCalibration.Count == 0)
		{
			List<BlankCalibration> blankCalibration = new List<BlankCalibration>();
			if (!XMLFile.Open(Application.StartupPath + "//iMassConfig//BlankCalibration.xml", ref blankCalibration))
			{
				experiment.BlankCalibration = new List<BlankCalibration>();
				experiment.BlankCalibration.Add(new BlankCalibration
				{
					Symbol = "5Bkg",
					Slope = 0.01,
					Intercept = -0.01
				});
				experiment.BlankCalibration.Add(new BlankCalibration
				{
					Symbol = "8Bkg",
					Slope = 0.01,
					Intercept = -0.01
				});
				experiment.BlankCalibration.Add(new BlankCalibration
				{
					Symbol = "101Bkg",
					Slope = 0.01,
					Intercept = -0.01
				});
				experiment.BlankCalibration.Add(new BlankCalibration
				{
					Symbol = "220Bkg",
					Slope = 0.01,
					Intercept = -0.01
				});
				experiment.BlankCalibration.Add(new BlankCalibration
				{
					Symbol = "245Bkg",
					Slope = 0.01,
					Intercept = -0.01
				});
			}
			else
			{
				experiment.BlankCalibration = blankCalibration;
			}
			experiment.Dirty.BlankCalibrationDirty = true;
		}
	}

	private void LoadExperimentDatas()
	{
		LoadAnlyteIsotopes();
		LoadSurveyRegions();
		LoadScanRegions();
		LoadPeakRegions();
		LoadIsotopes();
		LoadInterferenceEquations();
		LoadSamples();
		LoadStdConcentrations();
		LoadResults();
		LoadStatistics();
		LoadIsotopeRatios();
		LoadRatioResults();
		LoadRatioStatistcs();
		LoadCurves();
		LoadScanParams();
		LoadDisallowedRegions();
		LoadSpectrums();
		LoadReportParams();
		SemiCalculator.Calculator.Load();
		LoadQCSConcentrations();
		LoadQCSPara();
		LoadBlankCalibration();
		if (createFromOld)
		{
			experiment.SetUnTested();
			experiment.ChangePA();
		}
	}

	private void LoadInstrumentConfig()
	{
		Platform plat = db.GetPlatform("Experiment");
		if (plat != null)
		{
			experiment.CurrentPlat = plat;
		}
		else
		{
			experiment.CurrentPlat = PlatManager.plat.Clone();
		}
		X2Lens lens = db.GetX2Lens("Experiment");
		if (lens != null)
		{
			experiment.CurrentLens = lens;
		}
		else
		{
			experiment.CurrentLens = LensManager.x2lens.Clone();
		}
		PlasmaPara plasma = db.GetPlasma("Experiment");
		if (plasma != null)
		{
			experiment.CurrentPlasma = plasma;
		}
		else
		{
			experiment.CurrentPlasma = PlasmaManager.plasma.Clone();
		}
		RFS rfs = db.GetRFS("Experiment");
		if (rfs != null)
		{
			experiment.CurrentRFS = rfs;
		}
		else
		{
			experiment.CurrentRFS = RFManager.rfs.Clone();
		}
		AutoSampleTable autosamplet = db.GetAutoSampleTable();
		if (autosamplet != null)
		{
			experiment.AutosampleTable = autosamplet;
		}
		else
		{
			experiment.AutosampleTable = new AutoSampleTable();
			experiment.AutosampleTable.autoSample = false;
		}
		StableConfig stableconfig = db.GetStableConfig();
		if (stableconfig != null)
		{
			experiment.StableConfig = stableconfig;
		}
		else
		{
			experiment.StableConfig = new StableConfig();
			experiment.StableConfig.Stable = true;
			experiment.StableConfig.Time = 40;
		}
		Injector injector = db.GetInjector("Experiment");
		if (injector != null)
		{
			experiment.CurrentInjector = injector;
		}
		else
		{
			experiment.CurrentInjector = new Injector
			{
				Uptake = true,
				Wash = false,
				UptakeTime = 20,
				WashTime = 10,
				Perist = 350,
				PeristFast = 350,
				AutoWashTime = 5
			};
		}
		if (createFromOld)
		{
			int platId = experiment.CurrentPlat.id;
			int lensId = experiment.CurrentLens.id;
			int plasmaId = experiment.CurrentPlasma.Id;
			int rfsId = experiment.CurrentRFS.id;
			experiment.CurrentPlat = PlatManager.plat.Clone();
			experiment.CurrentPlat.id = platId;
			experiment.CurrentLens = LensManager.x2lens.Clone();
			experiment.CurrentLens.id = lensId;
			experiment.CurrentPlasma = PlasmaManager.plasma.Clone();
			experiment.CurrentPlasma.Id = plasmaId;
			experiment.CurrentRFS = RFManager.rfs.Clone();
			experiment.CurrentRFS.id = rfsId;
			Text = "default";
		}
	}

	public void RefreshResult(ExperimentDatas exp)
	{
		experiment = exp;
		if (formResults != null)
		{
			formResults.RefreshResults();
		}
	}

	private void LoadAnlyteIsotopes()
	{
		IList<AnalyteIsotope> isotopes = db.GetSelectAnlyteIsotopes();
		if (isotopes != null && isotopes.Count > 0)
		{
			experiment.SelectIsotopes = isotopes.ToList();
		}
	}

	private void LoadSurveyRegions()
	{
		IList<ScanRegions> surveyRegions = db.GetExpSurveyRegions();
		if (surveyRegions != null && surveyRegions.Count != 0)
		{
			experiment.SurveyRegions = surveyRegions;
			return;
		}
		experiment.SurveyRegions.Clear();
		experiment.SurveyRegions.Add(new ScanRegions(6.0, 8.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(8.0, 10.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(57.0, 59.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(88.0, 90.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(114.0, 116.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(139.0, 141.0, "Survey"));
		experiment.SurveyRegions.Add(new ScanRegions(208.0, 210.0, "Survey"));
	}

	private void LoadScanRegions()
	{
		IList<ScanRegions> scanRegions = db.GetExpScanRegions();
		if (scanRegions != null)
		{
			experiment.ScanRegions = scanRegions;
		}
	}

	private void LoadPeakRegions()
	{
		IList<PeakRegions> peakRegions = db.GetExpPeakRegions();
		if (peakRegions != null && peakRegions.Count() > 0)
		{
			experiment.PeakRegions = new List<PeakRegions>(peakRegions);
		}
	}

	private void LoadIsotopes()
	{
		IList<IsotopeInfos> isotopes = db.GetExpIsotopes();
		if (isotopes != null && isotopes.Count > 0)
		{
			experiment.Isotopes = new List<IsotopeInfos>(isotopes);
		}
	}

	private void LoadInterferenceEquations()
	{
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			if (isotope.withInterference)
			{
				int peakId = db.GetAnalyteIsotopeBySymbol(isotope.symbol).id;
				IList<InterferenceEquation> equations = db.GetInterferenceEquation(peakId);
				if (equations != null && equations.Count() > 0)
				{
					isotope.equations = new List<InterferenceEquation>(equations);
				}
			}
		}
	}

	private void LoadSamples()
	{
		IList<SamplesInfos> samples = db.GetExpSamples();
		if (samples != null && samples.Count > 0)
		{
			experiment.Samples = new List<SamplesInfos>(samples);
		}
	}

	private void LoadStdConcentrations()
	{
		IList<StandardConcentration> stdCon = db.GetExpStdConcs();
		if (stdCon != null && stdCon.Count > 0)
		{
			experiment.StdConcentration = new List<StandardConcentration>(stdCon);
		}
	}

	private void LoadQCSConcentrations()
	{
		IList<QCSConcentration> qcsCon = db.GetQCSConcs();
		if (qcsCon != null && qcsCon.Count > 0)
		{
			experiment.QCSConcentration = new List<QCSConcentration>(qcsCon);
		}
	}

	private void LoadResults()
	{
		IList<AnalyseInfos> results = db.GetExpResults();
		if (results != null && results.Count > 0)
		{
			experiment.Results = new List<AnalyseInfos>(results);
		}
	}

	private void LoadStatistics()
	{
		IList<StatisticResults> stat = db.GetExpStatistics();
		if (stat != null && stat.Count > 0)
		{
			experiment.Statistics = new List<StatisticResults>(stat);
		}
	}

	private void LoadIsotopeRatios()
	{
		IList<IsotopeRatio> ratios = db.GetExpIsotopeRatios();
		if (ratios != null && ratios.Count > 0)
		{
			experiment.Ratios = new List<IsotopeRatio>(ratios);
		}
	}

	private void LoadRatioResults()
	{
		IList<RatioResults> results = db.GetExpRatioResults();
		if (results != null && results.Count > 0)
		{
			experiment.RatioResults = new List<RatioResults>(results);
		}
	}

	private void LoadRatioStatistcs()
	{
		IList<RatioStatistics> statistics = db.GetExpRatioStatistics();
		if (statistics != null && statistics.Count > 0)
		{
			experiment.RatioStat = new List<RatioStatistics>(statistics);
		}
	}

	private void LoadSpectrums()
	{
		IList<SpectrumInfos> spectrums = db.GetExpSpectrums();
		if (spectrums != null && spectrums.Count > 0)
		{
			experiment.Spectrums = new List<SpectrumInfos>(spectrums);
		}
	}

	private void LoadCurves()
	{
		IList<IsotopeCurve> curves = db.GetExpCurves();
		if (curves != null && curves.Count > 0)
		{
			experiment.Curves = new List<IsotopeCurve>(curves);
		}
	}

	private void LoadScanParams()
	{
		ScanParams scan = db.GetExpParams();
		if (scan != null)
		{
			experiment.Scan = scan;
		}
	}

	private void LoadDisallowedRegions()
	{
		IList<ExclusionRegion> regions = db.GetExclusionRegions();
		if (regions == null)
		{
			return;
		}
		foreach (ExclusionRegion region in regions)
		{
			experiment.DisallowedRanges.Add(new PointF
			{
				X = (float)region.start,
				Y = (float)region.end
			});
		}
	}

	private void LoadReportParams()
	{
		ReportParams p = db.GetReportParams();
		if (p != null)
		{
			experiment.ReportParams = p;
		}
	}

	private void LoadQCSPara()
	{
		QCSPara p = db.GetQCSPara();
		if (p != null)
		{
			experiment.QCS = p;
		}
	}

	private void UnSelectAll()
	{
		Color color = Color.Black;
		Font font = new Font("Microsoft YaHei", 9f, FontStyle.Regular);
		tsbtnConfig.ForeColor = color;
		tsbtnConfig.Font = font;
		tsbtnConfig.Checked = false;
		tsbtnIsotopes.ForeColor = color;
		tsbtnIsotopes.Font = font;
		tsbtnIsotopes.Checked = false;
		tsbtnRatio.ForeColor = color;
		tsbtnRatio.Font = font;
		tsbtnRatio.Checked = false;
		tsbtnScan.ForeColor = color;
		tsbtnScan.Font = font;
		tsbtnScan.Checked = false;
		tsbtnStandards.ForeColor = color;
		tsbtnStandards.Font = font;
		tsbtnStandards.Checked = false;
		tsbtnMethod.ForeColor = color;
		tsbtnMethod.Font = font;
		tsbtnMethod.Checked = false;
		tsbtnSamples.ForeColor = color;
		tsbtnSamples.Font = font;
		tsbtnSamples.Checked = false;
		tsbtnConcen.ForeColor = color;
		tsbtnConcen.Font = font;
		tsbtnConcen.Checked = false;
		tsbtnResults.ForeColor = color;
		tsbtnResults.Font = font;
		tsbtnResults.Checked = false;
		tsbtnReport.ForeColor = color;
		tsbtnReport.Font = font;
		tsbtnReport.Checked = false;
	}

	private void tsbtnConfig_Click(object sender, EventArgs e)
	{
		if (!formConfig.Visible)
		{
			formConfig.SetParams(experiment, db);
			formConfig.TopLevel = false;
			formConfig.Parent = panelTest;
			formConfig.FormBorderStyle = FormBorderStyle.None;
			formConfig.Dock = DockStyle.Fill;
			formConfig.Show();
		}
		formConfig.Activate();
		formConfig.BringToFront();
		formConfig.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnIsotopes_Click(object sender, EventArgs e)
	{
		if (!formIsotopes.Visible)
		{
			formIsotopes.SetParams(experiment, db);
			formIsotopes.TopLevel = false;
			formIsotopes.Parent = panelTest;
			formIsotopes.FormBorderStyle = FormBorderStyle.None;
			formIsotopes.Dock = DockStyle.Fill;
			formIsotopes.Show();
		}
		formIsotopes.Activate();
		formIsotopes.BringToFront();
		formIsotopes.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnScan_Click(object sender, EventArgs e)
	{
		if (!formScan.Visible)
		{
			formScan.SetParams(experiment, db);
			formScan.TopLevel = false;
			formScan.Parent = panelTest;
			formScan.FormBorderStyle = FormBorderStyle.None;
			formScan.Dock = DockStyle.Fill;
			formScan.Show();
		}
		formScan.Activate();
		formScan.BringToFront();
		formScan.Size = panelTest.Size;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnInternal_Click(object sender, EventArgs e)
	{
		if (!formStandard.Visible)
		{
			formStandard.SetParams(experiment, db);
			formStandard.TopLevel = false;
			formStandard.Parent = panelTest;
			formStandard.FormBorderStyle = FormBorderStyle.None;
			formStandard.Dock = DockStyle.Fill;
			formStandard.Show();
			tsbtnStandards.CheckedChanged += formStandard.SelectedChanged;
		}
		formStandard.Activate();
		formStandard.BringToFront();
		formStandard.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnMethod_Click(object sender, EventArgs e)
	{
		if (!formMethod.Visible)
		{
			formMethod.SetParams(experiment, db);
			formMethod.TopLevel = false;
			formMethod.Parent = panelTest;
			formMethod.FormBorderStyle = FormBorderStyle.None;
			formMethod.Dock = DockStyle.Fill;
			formMethod.Show();
			tsbtnMethod.CheckedChanged += formMethod.SelectedChanged;
		}
		formMethod.Activate();
		formMethod.BringToFront();
		formMethod.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnSamples_Click(object sender, EventArgs e)
	{
		if (!formSamples.Visible)
		{
			formSamples.SetParams(experiment, db);
			formSamples.TopLevel = false;
			formSamples.Parent = panelTest;
			formSamples.FormBorderStyle = FormBorderStyle.None;
			formSamples.Dock = DockStyle.Fill;
			formSamples.Show();
			tsbtnSamples.CheckedChanged += formSamples.SelectedChanged;
		}
		formSamples.Activate();
		formSamples.BringToFront();
		formSamples.SetSurveyScanVisible();
		formSamples.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnConcen_Click(object sender, EventArgs e)
	{
		if (!formConcen.Visible)
		{
			formConcen.SetParams(experiment, db);
			formConcen.TopLevel = false;
			formConcen.Parent = panelTest;
			formConcen.FormBorderStyle = FormBorderStyle.None;
			formConcen.Dock = DockStyle.Fill;
			formConcen.Show();
		}
		formConcen.Activate();
		formConcen.BringToFront();
		formConcen.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnResults_Click(object sender, EventArgs e)
	{
		if (!formResults.Visible)
		{
			formResults.SetParams(experiment, db);
			formResults.TopLevel = false;
			formResults.Parent = panelTest;
			formResults.FormBorderStyle = FormBorderStyle.None;
			formResults.Dock = DockStyle.Fill;
			formResults.Show();
		}
		formResults.Activate();
		formResults.BringToFront();
		formResults.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnRatio_Click(object sender, EventArgs e)
	{
		if (!formRatio.Visible)
		{
			formRatio.SetParams(experiment, db);
			formRatio.TopLevel = false;
			formRatio.Parent = panelTest;
			formRatio.FormBorderStyle = FormBorderStyle.None;
			formRatio.Dock = DockStyle.Fill;
			formRatio.Show();
		}
		formRatio.Activate();
		formRatio.BringToFront();
		formRatio.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	private void tsbtnReport_Click(object sender, EventArgs e)
	{
		if (!formReport.Visible)
		{
			formReport.SetParams(experiment, db);
			formReport.TopLevel = false;
			formReport.Parent = panelTest;
			formReport.FormBorderStyle = FormBorderStyle.None;
			formReport.Dock = DockStyle.Fill;
			formReport.Show();
		}
		formReport.Activate();
		formReport.BringToFront();
		formReport.Parent = panelTest;
		UnSelectAll();
		(sender as ToolStripButton).ForeColor = Color.Red;
		(sender as ToolStripButton).Font = new Font("Microsoft YaHei", 9f, FontStyle.Bold);
		(sender as ToolStripButton).Checked = true;
	}

	public bool PreRun()
	{
		return experiment.PreRun();
	}

	public int StartAnalysis()
	{
		if (Detector.Instance.ExperimentState != -1)
		{
			if (Detector.Instance.ExperimentState == 5)
			{
				MessageBox.Show(Lang.Txt("AddFormExperiment.WaitTest"), Lang.Txt("AddFormExperiment.Warn"));
				return 0;
			}
			if (MessageBox.Show(Lang.Txt("AddFormExperiment.StopOtherTest"), Lang.Txt("AddFormExperiment.Warn"), MessageBoxButtons.YesNo) != DialogResult.Yes)
			{
				return 0;
			}
			Detector.Instance.ExperimentStateChange(Detector.Instance.ExperimentState);
		}
		ManualSaveDB();
		if (!isSaved)
		{
			return 0;
		}
		formConfig.SaveInject();
		IsRun = true;
		experiment.StartRun();
		return 0;
	}

	public void StopAnalysis()
	{
		if (experiment.IsRun)
		{
			experiment.StopRun();
			IsRun = false;
			ShowProgressStatus(Lang.Txt("FormExperiment.Status.EndAnalysis.Text"), 0);
		}
	}

	private void experiment_EventExperiment(object sendeer, ExperimentEventArgs e)
	{
		SamplesInfos sample = e.Sample;
		switch (e.StepIndex)
		{
		case -1:
			IsRun = false;
			if (this.analyseFinish != null && !FormSeqExperiment.IsRun)
			{
				this.analyseFinish(null, null);
			}
			if (experiment.AutosampleTable.autoSample && experiment.CurrentInjector.Wash && !FormSeqExperiment.IsRun)
			{
				AutoSampler.Instance.Rinse();
			}
			ShowProgressStatus(Lang.Txt("FormExperiment.Status.TimeOut.Text"), 0);
			Invoke((MethodInvoker)delegate
			{
				MessageBox.Show(Lang.Txt("FormExperiment.Status.TimeOut.Text"), Lang.Txt("AddFormExperiment.Warn"), MessageBoxButtons.OK);
			});
			break;
		case 0:
		{
			if (!IsRun)
			{
				break;
			}
			formResults.RefreshResults();
			if (experiment.CurrentInjector.Wash)
			{
				if (experiment.AutosampleTable.autoSample && experiment.CurrentInjector.Wash)
				{
					AutoSampler.Instance.Rinse();
					int time2 = experiment.CurrentInjector.WashTime;
					while (IsRun && time2-- > 0)
					{
						ShowProgressStatus(Lang.Txt("FormExperiment.Status.Wash.Text") + sample.label, (int)((double)time2 * 100.0 / (double)experiment.CurrentInjector.WashTime));
						Thread.Sleep(1000);
					}
				}
				else
				{
					FormWash formWash = new FormWash();
					if (formWash.ShowDialog() == DialogResult.OK)
					{
						int time = PlatManager.injector.WashTime;
						while (IsRun && time-- > 0)
						{
							ShowProgressStatus(Lang.Txt("FormExperiment.Status.Wash.Text") + sample.label, (int)((double)time * 100.0 / (double)PlatManager.injector.WashTime));
							Thread.Sleep(1000);
						}
					}
				}
			}
			if (!IsRun)
			{
				break;
			}
			formSamples.RefreshSamples();
			if (experiment.AutosampleTable.autoSample)
			{
				AutoSampler.Instance.MoveProbeABS(sample.rackNumber, sample.vialNumber, sample.ZDepth);
				if (experiment.CurrentInjector.Uptake)
				{
					PlatManager.injector.PeristFast = experiment.CurrentInjector.PeristFast;
					Plasma.Instance.PeristalticPumpOnFast();
					int uptaketime2 = PlatManager.injector.UptakeTime;
					while (IsRun && uptaketime2-- > 0)
					{
						ShowProgressStatus(string.Format(Lang.Txt("FormExperimetn.Status.TakeUp.Text") + "{0} {1}s", sample.label, uptaketime2), (int)((double)uptaketime2 * 100.0 / (double)PlatManager.injector.UptakeTime));
						Thread.Sleep(1000);
					}
					Plasma.Instance.PeristalticPumpOnNormal();
					if (experiment.StableConfig.Stable && !experiment.Scan.isSurvey)
					{
						experiment.bUptakeAndStableFinished = false;
						if (Detector.detectorConfig.IsNewBoard)
						{
							experiment.ExperimentForStableForNew();
						}
						else
						{
							experiment.ExperimentForStable();
						}
						int stabletime = experiment.StableConfig.Time;
						int lefttime = stabletime;
						while (IsRun && lefttime-- > 0)
						{
							ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime), (int)((double)lefttime * 100.0 / (double)stabletime));
							Thread.Sleep(1000);
						}
						ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
						experiment.bUptakeAndStableFinished = true;
						int WaitTime = 60;
						while (!experiment.bStableFunEnd && IsRun && WaitTime-- > 0)
						{
							Thread.Sleep(1000);
							ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
						}
						if (WaitTime <= 0)
						{
							Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
						}
					}
				}
				else if (experiment.StableConfig.Stable && !experiment.bUptakeAndStableFinished && !experiment.Scan.isSurvey)
				{
					PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
					Plasma.Instance.PeristalticPumpOnNormal();
					if (Detector.detectorConfig.IsNewBoard)
					{
						experiment.ExperimentForStableForNew();
					}
					else
					{
						experiment.ExperimentForStable();
					}
					int stabletime5 = experiment.StableConfig.Time;
					int lefttime5 = stabletime5;
					while (IsRun && lefttime5-- > 0)
					{
						ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime5), (int)((double)lefttime5 * 100.0 / (double)stabletime5));
						Thread.Sleep(1000);
					}
					ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
					experiment.bUptakeAndStableFinished = true;
					int WaitTime3 = 60;
					while (!experiment.bStableFunEnd && IsRun && WaitTime3-- > 0)
					{
						Thread.Sleep(1000);
						ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
					}
					if (WaitTime3 <= 0)
					{
						Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
					}
				}
				break;
			}
			if (FormSeqExperiment.IsRun)
			{
				if (experiment.AutosampleTable.autoSample)
				{
					if (experiment.CurrentInjector.Uptake)
					{
						AutoSampler.Instance.MoveProbeABS(sample.rackNumber, sample.vialNumber, sample.ZDepth);
						Plasma.Instance.PeristalticPumpOnFast();
						int uptaketime4 = experiment.CurrentInjector.UptakeTime;
						while (IsRun && uptaketime4-- > 0)
						{
							ShowProgressStatus(string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperimetn.Status.TakeUp.Text") + "{0} {1}s", sample.label, uptaketime4), (int)((double)uptaketime4 * 100.0 / (double)experiment.CurrentInjector.UptakeTime));
							Thread.Sleep(1000);
						}
						PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
						Plasma.Instance.PeristalticPumpOnNormal();
						if (experiment.StableConfig.Stable && !experiment.Scan.isSurvey)
						{
							experiment.bUptakeAndStableFinished = false;
							if (Detector.detectorConfig.IsNewBoard)
							{
								experiment.ExperimentForStableForNew();
							}
							else
							{
								experiment.ExperimentForStable();
							}
							int stabletime7 = experiment.StableConfig.Time;
							int lefttime7 = stabletime7;
							while (IsRun && lefttime7-- > 0)
							{
								ShowProgressStatus(string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime7), (int)((double)lefttime7 * 100.0 / (double)stabletime7));
								Thread.Sleep(1000);
							}
							ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
							experiment.bUptakeAndStableFinished = true;
							int WaitTime6 = 60;
							while (!experiment.bStableFunEnd && IsRun && WaitTime6-- > 0)
							{
								Thread.Sleep(1000);
								ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
							}
							if (WaitTime6 <= 0)
							{
								Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
							}
						}
					}
					else if (experiment.StableConfig.Stable && !experiment.bUptakeAndStableFinished)
					{
						PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
						Plasma.Instance.PeristalticPumpOnNormal();
						if (Detector.detectorConfig.IsNewBoard)
						{
							experiment.ExperimentForStableForNew();
						}
						else
						{
							experiment.ExperimentForStable();
						}
						int stabletime9 = experiment.StableConfig.Time;
						int lefttime9 = stabletime9;
						while (IsRun && lefttime9-- > 0)
						{
							ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime9), (int)((double)lefttime9 * 100.0 / (double)stabletime9));
							Thread.Sleep(1000);
						}
						ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
						experiment.bUptakeAndStableFinished = true;
						int WaitTime9 = 60;
						while (!experiment.bStableFunEnd && IsRun && WaitTime9-- > 0)
						{
							Thread.Sleep(1000);
							ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
						}
						if (WaitTime9 <= 0)
						{
							Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
						}
					}
				}
				else if (experiment.IsFirst)
				{
					FormUptake dlg2 = new FormUptake();
					dlg2.Samplename = sample.label;
					dlg2.SetParams(experiment);
					if (dlg2.ShowDialog() == DialogResult.OK)
					{
						if (experiment.CurrentInjector.Uptake)
						{
							PlatManager.injector.PeristFast = experiment.CurrentInjector.PeristFast;
							Plasma.Instance.PeristalticPumpOnFast();
							int uptaketime3 = experiment.CurrentInjector.UptakeTime;
							while (IsRun && uptaketime3-- > 0)
							{
								ShowProgressStatus(string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperimetn.Status.TakeUp.Text") + "{0} {1}s", sample.label, uptaketime3), (int)((double)uptaketime3 * 100.0 / (double)PlatManager.injector.UptakeTime));
								Thread.Sleep(1000);
							}
							PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
							Plasma.Instance.PeristalticPumpOnNormal();
							if (experiment.StableConfig.Stable && !experiment.Scan.isSurvey)
							{
								experiment.bUptakeAndStableFinished = false;
								if (Detector.detectorConfig.IsNewBoard)
								{
									experiment.ExperimentForStableForNew();
								}
								else
								{
									experiment.ExperimentForStable();
								}
								int stabletime8 = experiment.StableConfig.Time;
								int lefttime8 = stabletime8;
								while (IsRun && lefttime8-- > 0)
								{
									ShowProgressStatus(string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime8), (int)((double)lefttime8 * 100.0 / (double)stabletime8));
									Thread.Sleep(1000);
								}
								ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
								experiment.bUptakeAndStableFinished = true;
								int WaitTime8 = 60;
								while (!experiment.bStableFunEnd && IsRun && WaitTime8-- > 0)
								{
									Thread.Sleep(1000);
									ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
								}
								if (WaitTime8 <= 0)
								{
									Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
								}
							}
						}
						else if (experiment.StableConfig.Stable && !experiment.bUptakeAndStableFinished)
						{
							PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
							Plasma.Instance.PeristalticPumpOnNormal();
							if (Detector.detectorConfig.IsNewBoard)
							{
								experiment.ExperimentForStableForNew();
							}
							else
							{
								experiment.ExperimentForStable();
							}
							int stabletime6 = experiment.StableConfig.Time;
							int lefttime6 = stabletime6;
							while (IsRun && lefttime6-- > 0)
							{
								ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime6), (int)((double)lefttime6 * 100.0 / (double)stabletime6));
								Thread.Sleep(1000);
							}
							ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
							experiment.bUptakeAndStableFinished = true;
							int WaitTime7 = 60;
							while (!experiment.bStableFunEnd && IsRun && WaitTime7-- > 0)
							{
								Thread.Sleep(1000);
								ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
							}
							if (WaitTime7 <= 0)
							{
								Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
							}
						}
					}
					else
					{
						if (this.analyseFinish != null)
						{
							this.analyseFinish(null, null);
						}
						if (experiment.AutosampleTable.autoSample && experiment.CurrentInjector.Wash && !FormSeqExperiment.IsRun)
						{
							AutoSampler.Instance.Rinse();
						}
						StopAnalysis();
						FormSeqExperiment.OnAnalysisFinish();
					}
				}
				else if (experiment.StableConfig.Stable && !experiment.bUptakeAndStableFinished)
				{
					PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
					Plasma.Instance.PeristalticPumpOnNormal();
					if (Detector.detectorConfig.IsNewBoard)
					{
						experiment.ExperimentForStableForNew();
					}
					else
					{
						experiment.ExperimentForStable();
					}
					int stabletime4 = experiment.StableConfig.Time;
					int lefttime4 = stabletime4;
					while (IsRun && lefttime4-- > 0)
					{
						ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime4), (int)((double)lefttime4 * 100.0 / (double)stabletime4));
						Thread.Sleep(1000);
					}
					ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
					experiment.bUptakeAndStableFinished = true;
					int WaitTime5 = 60;
					while (!experiment.bStableFunEnd && IsRun && WaitTime5-- > 0)
					{
						Thread.Sleep(1000);
						ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
					}
					if (WaitTime5 <= 0)
					{
						Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
					}
				}
				break;
			}
			FormUptake dlg = new FormUptake();
			dlg.Samplename = sample.label;
			dlg.SetParams(experiment);
			if (dlg.ShowDialog() == DialogResult.OK)
			{
				if (experiment.CurrentInjector.Uptake)
				{
					Plasma.Instance.PeristalticPumpOnFast();
					int uptaketime = experiment.CurrentInjector.UptakeTime;
					while (IsRun && uptaketime-- > 0)
					{
						ShowProgressStatus(string.Format(Lang.Txt("FormExperimetn.Status.TakeUp.Text") + "{0} {1}s", sample.label, uptaketime), (int)((double)uptaketime * 100.0 / (double)PlatManager.injector.UptakeTime));
						Thread.Sleep(1000);
					}
					PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
					Plasma.Instance.PeristalticPumpOnNormal();
					if (experiment.StableConfig.Stable && !experiment.Scan.isSurvey)
					{
						experiment.bUptakeAndStableFinished = false;
						if (Detector.detectorConfig.IsNewBoard)
						{
							experiment.ExperimentForStableForNew();
						}
						else
						{
							experiment.ExperimentForStable();
						}
						int stabletime3 = experiment.StableConfig.Time;
						int lefttime3 = stabletime3;
						while (IsRun && lefttime3-- > 0)
						{
							ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime3), (int)((double)lefttime3 * 100.0 / (double)stabletime3));
							Thread.Sleep(1000);
						}
						ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
						experiment.bUptakeAndStableFinished = true;
						int WaitTime4 = 60;
						while (!experiment.bStableFunEnd && IsRun && WaitTime4-- > 0)
						{
							Thread.Sleep(1000);
							ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
						}
						if (WaitTime4 <= 0)
						{
							Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
						}
					}
				}
				else if (experiment.StableConfig.Stable && !experiment.Scan.isSurvey && !experiment.bUptakeAndStableFinished)
				{
					experiment.bUptakeAndStableFinished = false;
					PlatManager.injector.Perist = experiment.CurrentInjector.Perist;
					Plasma.Instance.PeristalticPumpOnNormal();
					if (Detector.detectorConfig.IsNewBoard)
					{
						experiment.ExperimentForStableForNew();
					}
					else
					{
						experiment.ExperimentForStable();
					}
					int stabletime2 = experiment.StableConfig.Time;
					int lefttime2 = stabletime2;
					while (IsRun && lefttime2-- > 0)
					{
						ShowProgressStatus(string.Format(Lang.Txt("FormExperiment.Status.Delay.Text") + "{0} {1}s", sample.label, lefttime2), (int)((double)lefttime2 * 100.0 / (double)stabletime2));
						Thread.Sleep(1000);
					}
					ShowProgressStatus(Lang.Txt("FormExperiment.Status.StartAnalysis.Text") + sample.label, 0);
					experiment.bUptakeAndStableFinished = true;
					int WaitTime2 = 60;
					while (!experiment.bStableFunEnd && IsRun && WaitTime2-- > 0)
					{
						Thread.Sleep(1000);
						ShowProgressStatus(Lang.Txt("AddFormExperiment.WaitingEnd"), 0);
					}
					if (WaitTime2 <= 0)
					{
						Log.InsertLog(Lang.Txt("AddFormExperiment.StabProcess"), Lang.Txt("AddFormExperiment.StabTimeout"), Detector.finishEvent(), (Severity)3);
					}
				}
			}
			else
			{
				StopAnalysis();
				if (this.analyseFinish != null && !FormSeqExperiment.IsRun)
				{
					this.analyseFinish(null, null);
				}
				if (experiment.AutosampleTable.autoSample && experiment.CurrentInjector.Wash && !FormSeqExperiment.IsRun)
				{
					AutoSampler.Instance.Rinse();
				}
			}
			break;
		}
		case 1:
		case 2:
		{
			string msg = "";
			msg = ((e.RunIndex != 0) ? (string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperiment.Sample.Text ") + "{0} {1} " + Lang.Txt("FormExperiment.Status.Run.Text") + "{2} " + Lang.Txt("FormExperiment.Status.Sweep.Text") + "{3}", sample.label, (e.StepIndex == 1) ? Lang.Txt("FormExperiment.Survey.Text") : Lang.Txt("FormExperiment.Experiment.Text"), e.RunIndex, e.SweepIndex)) : (string.Format(experimentPath.Split('\\').Last()) + string.Format(Lang.Txt("FormExperiment.Sample.Text ") + "{0} {1} " + Lang.Txt("FormExperiment.Status.ProcessResult"), sample.label, (e.StepIndex == 1) ? Lang.Txt("FormExperiment.Survey.Text") : Lang.Txt("FormExperiment.Experiment.Text"))));
			ShowProgressStatus(msg, 0);
			break;
		}
		case 3:
			IsRun = false;
			if (this.analyseFinish != null && !FormSeqExperiment.IsRun)
			{
				this.analyseFinish(null, null);
			}
			if (experiment.AutosampleTable.autoSample && experiment.CurrentInjector.Wash && !FormSeqExperiment.IsRun)
			{
				AutoSampler.Instance.Rinse();
			}
			if (Detector.detectorConfig.IsNewBoard)
			{
				RFManager.rfs.Gate = (float)((double)RFManager.rfs.HVP * 0.23);
				if (Detector.detectorConfig.IsNewDetector)
				{
					Detector.Instance.msDetectorRF.SetGateNew();
				}
				else
				{
					Detector.Instance.msDetectorRF.SetGate();
				}
			}
			ShowProgressStatus(Lang.Txt("FormExperiment.Status.EndAnalysis.Text"), 0);
			if (!FormSeqExperiment.IsRun)
			{
				Invoke((MethodInvoker)delegate
				{
					MessageBox.Show(Lang.Txt("FormExperiment.Status.EndAnalysis.Text"), Lang.Txt("AddFormExperiment.Warn"), MessageBoxButtons.OK);
				});
			}
			break;
		case 5:
			ProcessAndSaveSingleSample(e.Sample);
			break;
		case 6:
			formResults.RefreshResultsSingle(e.Sample);
			break;
		case 4:
			break;
		}
	}

	private void ShowProgressStatus(string msg, int percent)
	{
		if (this.ExpEvent != null)
		{
			this.ExpEvent(this, new ExpProgressArgs(msg, percent));
		}
	}

	private void tsmi_LIMS_Click(object sender, EventArgs e)
	{
		FormLIMS formLims = new FormLIMS();
		List<string> files = new List<string>();
		LimsConverter lims = new LimsConverter();
		string limsPath = Application.StartupPath + "/lims.xml";
		if (Directory.Exists(limsPath))
		{
			XMLFileBinary.Open(limsPath, ref lims);
		}
		if (lims == null)
		{
			lims = new LimsConverter();
		}
		formLims.HostIP = lims.HostIP;
		formLims.HostPort = lims.HostPort;
		formLims.SerialPort = lims.SerialPort;
		formLims.LimsType = lims.LimsType;
		formLims.FileDir = lims.FileDir;
		if (formLims.ShowDialog() == DialogResult.OK)
		{
			lims.HostIP = formLims.HostIP;
			lims.HostPort = formLims.HostPort;
			lims.SerialPort = formLims.SerialPort;
			lims.LimsType = formLims.LimsType;
			lims.FileDir = formLims.FileDir;
			lims.SendFile(ExportConditionFile(experiment, lims.FileDir));
			lims.SendFile(ExportDataFile(experiment, lims.FileDir));
			XMLFileBinary.Save(limsPath, lims);
		}
	}

	private string ExportConditionFile(ExperimentDatas experiment, string filedir)
	{
		string filename = filedir + "//" + DateTime.Now.ToString() + "data.csv";
		using (StreamWriter sw = new StreamWriter(filename))
		{
			try
			{
				sw.Write(Lang.Txt("FormConfig.Columns.Extraction.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.Ex);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.D2.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.D2);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Hexapole.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.Pole);
				sw.WriteLine();
				sw.Write("D1");
				sw.Write(",");
				sw.Write(experiment.CurrentLens.D1);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.DA.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.DA);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.QE.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.QE);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.F.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.F);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.L1.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.L1);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.L2.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.L2);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.L3.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentLens.L3);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Power.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Power);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.QuadPole.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentRFS.quadPole);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Collsion.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Collision);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Collsion2.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Collision2);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Nebulizer.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Auxiliary);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Carrier.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Nebuliser);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.CoolGas.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlasma.Cool);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.X.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlat.X);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Y.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlat.Y);
				sw.WriteLine();
				sw.Write(Lang.Txt("FormConfig.Columns.Z.Text"));
				sw.Write(",");
				sw.Write(experiment.CurrentPlat.Z);
				sw.WriteLine();
			}
			catch (Exception)
			{
				return null;
			}
		}
		return filename;
	}

	private string ExportDataFile(ExperimentDatas experiment, string filedir)
	{
		string filename = filedir + "//" + DateTime.Now.ToString() + "data.csv";
		using (StreamWriter sw = new StreamWriter(filename))
		{
			try
			{
				sw.Write(" ");
				foreach (IsotopeInfos isotope5 in experiment.Isotopes)
				{
					sw.Write(",");
					sw.Write(isotope5.symbol);
					sw.Write("");
					sw.Write(",");
					sw.Write("");
					sw.Write(",");
				}
				sw.WriteLine();
				foreach (SamplesInfos sample in experiment.Samples)
				{
					if (sample.status != 1 || !sample.report)
					{
						continue;
					}
					sw.WriteLine();
					sw.WriteLine(sample.label);
					for (int i = 0; i < sample.mains; i++)
					{
						sw.Write(i + 1);
						foreach (IsotopeInfos isotope4 in experiment.Isotopes)
						{
							sw.Write(",");
							AnalyseInfos r4 = experiment.Results.Where((AnalyseInfos result) => result.sampleId == sample.guid && result.number == i && result.symbol == isotope4.symbol).First();
							sw.Write(r4.concentration);
							sw.Write(",");
							sw.Write(r4.intensity);
							sw.Write(",");
							sw.Write(r4.icps);
							sw.Write(",");
						}
						sw.WriteLine();
					}
					sw.Write("average");
					foreach (IsotopeInfos isotope3 in experiment.Isotopes)
					{
						sw.Write(",");
						StatisticResults r3 = experiment.Statistics.Where((StatisticResults result) => result.sampleId == sample.guid && result.symbol == isotope3.symbol).First();
						sw.Write(r3.avgCon);
						sw.Write(",");
						sw.Write(r3.avgUICPS);
						sw.Write(",");
						sw.Write(r3.avgCPS);
						sw.Write(",");
					}
					sw.WriteLine();
					sw.Write("deviation");
					foreach (IsotopeInfos isotope2 in experiment.Isotopes)
					{
						sw.Write(",");
						StatisticResults r2 = experiment.Statistics.Where((StatisticResults result) => result.sampleId == sample.guid && result.symbol == isotope2.symbol).First();
						sw.Write(r2.sdCon);
						sw.Write(",");
						sw.Write(r2.sdUICPS);
						sw.Write(",");
						sw.Write(r2.sdCPS);
						sw.Write(",");
					}
					sw.WriteLine();
					sw.Write("%RSD");
					foreach (IsotopeInfos isotope in experiment.Isotopes)
					{
						sw.Write(",");
						StatisticResults r = experiment.Statistics.Where((StatisticResults result) => result.sampleId == sample.guid && result.symbol == isotope.symbol).First();
						sw.Write(r.rsdCon);
						sw.Write(",");
						sw.Write(r.rsdUICPS);
						sw.Write(",");
						sw.Write(r.rsdCPS);
						sw.Write(",");
					}
					sw.WriteLine();
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, Lang.Txt("AddFormExperiment.Warn"), MessageBoxButtons.OK);
				return null;
			}
		}
		return filename;
	}

	private void button1_Click(object sender, EventArgs e)
	{
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ICP_MS.Plugin.Experiment.FormExperiment));
		this.groupBox13 = new System.Windows.Forms.GroupBox();
		this.label8 = new System.Windows.Forms.Label();
		this.menuStrip1 = new System.Windows.Forms.MenuStrip();
		this.kHome = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmiSave = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmiSaveAs = new System.Windows.Forms.ToolStripMenuItem();
		this.tsmi_LIMS = new System.Windows.Forms.ToolStripMenuItem();
		this.toolStrip1 = new System.Windows.Forms.ToolStrip();
		this.tsbtnConfig = new System.Windows.Forms.ToolStripButton();
		this.tsbtnIsotopes = new System.Windows.Forms.ToolStripButton();
		this.tsbtnScan = new System.Windows.Forms.ToolStripButton();
		this.tsbtnStandards = new System.Windows.Forms.ToolStripButton();
		this.tsbtnRatio = new System.Windows.Forms.ToolStripButton();
		this.tsbtnMethod = new System.Windows.Forms.ToolStripButton();
		this.tsbtnSamples = new System.Windows.Forms.ToolStripButton();
		this.tsbtnConcen = new System.Windows.Forms.ToolStripButton();
		this.tsbtnResults = new System.Windows.Forms.ToolStripButton();
		this.tsbtnReport = new System.Windows.Forms.ToolStripButton();
		this.panelTest = new System.Windows.Forms.Panel();
		this.groupBox13.SuspendLayout();
		this.menuStrip1.SuspendLayout();
		this.toolStrip1.SuspendLayout();
		base.SuspendLayout();
		this.groupBox13.Controls.Add(this.label8);
		this.groupBox13.Dock = System.Windows.Forms.DockStyle.Top;
		this.groupBox13.Location = new System.Drawing.Point(3, 3);
		this.groupBox13.Name = "groupBox13";
		this.groupBox13.Size = new System.Drawing.Size(764, 57);
		this.groupBox13.TabIndex = 1;
		this.groupBox13.TabStop = false;
		this.groupBox13.Text = "单位";
		this.label8.AutoSize = true;
		this.label8.Location = new System.Drawing.Point(41, 27);
		this.label8.Name = "label8";
		this.label8.Size = new System.Drawing.Size(67, 13);
		this.label8.TabIndex = 3;
		this.label8.Text = "浓度单位：";
		this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
		this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.kHome });
		this.menuStrip1.Location = new System.Drawing.Point(0, 0);
		this.menuStrip1.Name = "menuStrip1";
		this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2);
		this.menuStrip1.Size = new System.Drawing.Size(1005, 25);
		this.menuStrip1.TabIndex = 1;
		this.menuStrip1.Text = "menuStrip1";
		this.menuStrip1.Visible = false;
		this.kHome.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[3] { this.tsmiSave, this.tsmiSaveAs, this.tsmi_LIMS });
		this.kHome.MergeAction = System.Windows.Forms.MergeAction.MatchOnly;
		this.kHome.Name = "kHome";
		this.kHome.Size = new System.Drawing.Size(58, 21);
		this.kHome.Text = "文件(&F)";
		this.tsmiSave.Name = "tsmiSave";
		this.tsmiSave.Size = new System.Drawing.Size(180, 22);
		this.tsmiSave.Text = "保存";
		this.tsmiSave.Click += new System.EventHandler(tsmiSave_Click);
		this.tsmiSaveAs.Name = "tsmiSaveAs";
		this.tsmiSaveAs.Size = new System.Drawing.Size(180, 22);
		this.tsmiSaveAs.Text = "另存为";
		this.tsmiSaveAs.Click += new System.EventHandler(tsmiSaveAs_Click);
		this.tsmi_LIMS.Name = "tsmi_LIMS";
		this.tsmi_LIMS.Size = new System.Drawing.Size(180, 22);
		this.tsmi_LIMS.Text = "LIMS(&L)";
		this.tsmi_LIMS.Click += new System.EventHandler(tsmi_LIMS_Click);
		this.toolStrip1.AutoSize = false;
		this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
		this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[10] { this.tsbtnConfig, this.tsbtnIsotopes, this.tsbtnScan, this.tsbtnStandards, this.tsbtnRatio, this.tsbtnMethod, this.tsbtnSamples, this.tsbtnConcen, this.tsbtnResults, this.tsbtnReport });
		this.toolStrip1.Location = new System.Drawing.Point(0, 25);
		this.toolStrip1.Name = "toolStrip1";
		this.toolStrip1.Size = new System.Drawing.Size(1005, 55);
		this.toolStrip1.TabIndex = 2;
		this.toolStrip1.Text = "toolStrip1";
		this.tsbtnConfig.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnConfig.Image = (System.Drawing.Image)resources.GetObject("tsbtnConfig.Image");
		this.tsbtnConfig.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnConfig.Name = "tsbtnConfig";
		this.tsbtnConfig.Size = new System.Drawing.Size(60, 52);
		this.tsbtnConfig.Text = "扫描条件";
		this.tsbtnConfig.Click += new System.EventHandler(tsbtnConfig_Click);
		this.tsbtnIsotopes.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnIsotopes.Image = (System.Drawing.Image)resources.GetObject("tsbtnIsotopes.Image");
		this.tsbtnIsotopes.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnIsotopes.Name = "tsbtnIsotopes";
		this.tsbtnIsotopes.Size = new System.Drawing.Size(60, 52);
		this.tsbtnIsotopes.Text = "分析元素";
		this.tsbtnIsotopes.Click += new System.EventHandler(tsbtnIsotopes_Click);
		this.tsbtnScan.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnScan.Image = (System.Drawing.Image)resources.GetObject("tsbtnScan.Image");
		this.tsbtnScan.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnScan.Name = "tsbtnScan";
		this.tsbtnScan.Size = new System.Drawing.Size(60, 52);
		this.tsbtnScan.Text = "扫描参数";
		this.tsbtnScan.Click += new System.EventHandler(tsbtnScan_Click);
		this.tsbtnStandards.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnStandards.Image = (System.Drawing.Image)resources.GetObject("tsbtnStandards.Image");
		this.tsbtnStandards.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnStandards.Name = "tsbtnStandards";
		this.tsbtnStandards.Size = new System.Drawing.Size(60, 52);
		this.tsbtnStandards.Text = "内标设置";
		this.tsbtnStandards.Click += new System.EventHandler(tsbtnInternal_Click);
		this.tsbtnRatio.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnRatio.Image = (System.Drawing.Image)resources.GetObject("tsbtnRatio.Image");
		this.tsbtnRatio.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnRatio.Name = "tsbtnRatio";
		this.tsbtnRatio.Size = new System.Drawing.Size(60, 52);
		this.tsbtnRatio.Text = "比率设置";
		this.tsbtnRatio.Click += new System.EventHandler(tsbtnRatio_Click);
		this.tsbtnMethod.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnMethod.Image = (System.Drawing.Image)resources.GetObject("tsbtnMethod.Image");
		this.tsbtnMethod.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnMethod.Name = "tsbtnMethod";
		this.tsbtnMethod.Size = new System.Drawing.Size(60, 52);
		this.tsbtnMethod.Text = "校正设置";
		this.tsbtnMethod.Click += new System.EventHandler(tsbtnMethod_Click);
		this.tsbtnSamples.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnSamples.Image = (System.Drawing.Image)resources.GetObject("tsbtnSamples.Image");
		this.tsbtnSamples.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnSamples.Name = "tsbtnSamples";
		this.tsbtnSamples.Size = new System.Drawing.Size(60, 52);
		this.tsbtnSamples.Text = "样品列表";
		this.tsbtnSamples.Click += new System.EventHandler(tsbtnSamples_Click);
		this.tsbtnConcen.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnConcen.Image = (System.Drawing.Image)resources.GetObject("tsbtnConcen.Image");
		this.tsbtnConcen.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnConcen.Name = "tsbtnConcen";
		this.tsbtnConcen.Size = new System.Drawing.Size(60, 52);
		this.tsbtnConcen.Text = "标样浓度";
		this.tsbtnConcen.Click += new System.EventHandler(tsbtnConcen_Click);
		this.tsbtnResults.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnResults.Image = (System.Drawing.Image)resources.GetObject("tsbtnResults.Image");
		this.tsbtnResults.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnResults.Name = "tsbtnResults";
		this.tsbtnResults.Size = new System.Drawing.Size(60, 52);
		this.tsbtnResults.Text = "扫描结果";
		this.tsbtnResults.Click += new System.EventHandler(tsbtnResults_Click);
		this.tsbtnReport.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
		this.tsbtnReport.Image = (System.Drawing.Image)resources.GetObject("tsbtnReport.Image");
		this.tsbtnReport.ImageTransparentColor = System.Drawing.Color.Magenta;
		this.tsbtnReport.Name = "tsbtnReport";
		this.tsbtnReport.Size = new System.Drawing.Size(60, 52);
		this.tsbtnReport.Text = "打印报告";
		this.tsbtnReport.Click += new System.EventHandler(tsbtnReport_Click);
		this.panelTest.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panelTest.Location = new System.Drawing.Point(0, 80);
		this.panelTest.Margin = new System.Windows.Forms.Padding(0);
		this.panelTest.Name = "panelTest";
		this.panelTest.Size = new System.Drawing.Size(1005, 533);
		this.panelTest.TabIndex = 3;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1005, 613);
		base.Controls.Add(this.panelTest);
		base.Controls.Add(this.toolStrip1);
		base.Controls.Add(this.menuStrip1);
		base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
		base.MainMenuStrip = this.menuStrip1;
		base.Name = "FormExperiment";
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "测试";
		base.WindowState = System.Windows.Forms.FormWindowState.Maximized;
		base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormExperiment_FormClosing);
		base.Load += new System.EventHandler(FormExperiment_Load);
		this.groupBox13.ResumeLayout(false);
		this.groupBox13.PerformLayout();
		this.menuStrip1.ResumeLayout(false);
		this.menuStrip1.PerformLayout();
		this.toolStrip1.ResumeLayout(false);
		this.toolStrip1.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
